# coding=utf-8

import os
import sys

# urllib库不兼容Python2和Python3，对2和3版本进行区分
if sys.version[0] == '2':
    import urllib
    import urllib2
    from io import StringIO
elif sys.version[0] == '3':
    import urllib
    import urllib.parse

import datetime
import pymongo
from bson.objectid import ObjectId
import bson
import json


"""
判断存储内容是否为中文Chinese
"""
def isChinese(ustring):
    for item in ustring:
        try:
            if u'\u4e00' <= item <= u'\u9fff':
                return True
        except UnicodeDecodeError:
            return True
    return False


'''
MongoDB配置类
'''
class MyMongoDBConfig():
    def __init__(self):
        pass

    @classmethod
    def analysisUrl(self, mongoDBUrl):
        # 解析url
        tmp = mongoDBUrl.split('//')[1]
        host = tmp.split(':')[0]
        port = tmp.split(':')[-1]
        return host, port


